package com.crm.dao.saling;

import com.crm.pojo.Refund;
import com.crm.vo.RefundContractClient;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.sql.Ref;
import java.util.List;

/**
 * Created by dr5hx on 2018/8/10
 */
public interface RefundDao extends CrudRepository<Refund, Long> {
    @Query("from Refund r where r.refundIsDel='否'")
    public List<Refund> showRefundList(Pageable pageable);
    @Query("from Refund r where r.refundIsDel='否'")
    public List<Refund> findAllBymh();

    /**
     * 显示退款单列表
     *
     * @param pageable
     * @return
     */
    @Query("select new com.crm.vo.RefundContractClient(refund,contract,clientInfo ) from Refund refund,Contract contract,ClientInfo clientInfo where refund.refundIsDel='否' and refund.fkRefundContractId=contract.contractId and contract.fkCustomerId=clientInfo.cid")
    public List<RefundContractClient> getRefundContractClientList(Pageable pageable);

    /**
     * 退款单总数
     *
     * @return
     */
    @Query("select count(refund) from Refund  refund where refund.refundIsDel='否'")
    public Long getRefundCount();
}
